﻿@inherits System.Web.Mvc.WebViewPage
<div class="search-page" style="min-width:100%;padding:0;">
    <table class="table">
        <thead>
            <tr>
                <th>公文标题</th>
                <th>指派人员</th>
                <th>指派时间</th>
                <th>超时时长(小时)</th>
            </tr>
        </thead>
        <tbody id="monitorHistory">
        </tbody>
    </table>
</div>

<input id="deptID" type="text" value="@ViewBag.deptID" hidden="hidden" />
<input id="delayTime" type="text" value="@ViewBag.delayTime" hidden="hidden"/>
<input id="startTime" type="text" value="@ViewBag.startTime" hidden="hidden"/>
<input id="endTime" type="text" value="@ViewBag.endTime" hidden="hidden"/>
<script>
    $(document).ready(function () {
        // 加载数据
        $.ajax({
            url: '/Apps/Archives/WorkflowQuery/GetTheDeptMonitor',
            type: 'POST',
            data: {
                'deptID': $('#deptID').val(),
                'delayTime': $('#delayTime').val(),
                'startTime': $('#startTime').val(),
                'endTime': $('#endTime').val()
            },
            success: function (result) {
                console.log(result);
                var tableStr = '';
                $('#monitorHistory').empty();
                result.Data.forEach(function (item, index) {
                    tableStr += '<tr> \
                    <td title="' + (item.DocumentTitle == '' ? '----' : item.DocumentTitle) + '" class="item-lg"><a href="/Apps/Workflow/Running/Open?mid=' + item.MessageId + '" target="_blank">' + (item.DocumentTitle == '' ? '----' : item.DocumentTitle) + '</a></td> \
                    <td>' + getSplitString(item.Users) + '</td> \
                    <td>' + getSplitString(item.CreateTime) + '</td> \
                    <td>' + getSplitString(item.DelayTime) + '</td> \
                </tr>';
                });
                $('#monitorHistory').append(tableStr);
            },
            error: function (error) {
                console.log(error);
            }
        });

        // 获得分割后的字符串
        function getSplitString(items) {
            var connectedString = '';
            var splitedArray = items.split(',');
            splitedArray.forEach(function (item) {
                connectedString += ('<p>' + item + '</p>');
            });

            return connectedString;
        }
    });
</script>

